Wp7 / Silverlight] How to animate a ListBoxItem on SelectionChanged?

Well, after try and error I came up with a solution, but it's not exactly what I wanted (the storyboard defined outside the datatemplate and maybe less code. I think it's too much for just flipping an image), but very close.

Up vote 1 down vote favorite 1 share g+ share fb share tw.

I'm developing an app (VisualStudio 2010 Express for Windows Phone). I have a listbox with images and a storyboard with an animation (a projection) that I want to apply to a specific listboxitem/image when the SelectionChanged event gets fired (well not immediatly but inside the event handler). How can I "link" my animation to this specific ListBoxItem?

Silverlight windows-phone-7 link|improve this question edited Oct 25 '10 at 16:17Nate8,75742765 asked Oct 25 '10 at 16:17Felipe Guajardo70110 80% accept rate.

Well, after try and error I came up with a solution, but it's not exactly what I wanted (the storyboard defined outside the datatemplate and maybe less code. I think it's too much for just flipping an image), but very close. So, the example listbox: And the Code behind: private void lbxCardTable_SelectionChanged(object sender, SelectionChangedEventArgs e) { object selectedItem = lbxCardTable.

SelectedItem; ListBoxItem lbitem = (ListBoxItem)lbxCardTable. ItemContainerGenerator. ContainerFromItem(selectedItem); var border =(Border) VisualTreeHelper.

GetChild(lbitem, 0); var mcontentcontrol =(ContentControl) VisualTreeHelper. GetChild(border, 0); var contentpresenter =(ContentPresenter) VisualTreeHelper. GetChild(mcontentcontrol, 0); var mgrid=(Grid)VisualTreeHelper.

GetChild(contentpresenter,0); Storyboard sb = mgrid. Resources"itemSb" as Storyboard; if (sb.GetCurrentState()! = ClockState.

Stopped) { sb.Stop(); } sb.Begin(); }.

Check this post: "Animating ListBox SelectedItem with flipping effect in WP7" Hope this will help you.

Thanks for your answer and time, but as I stated (maybe not clear enough) I wanted to start the animation inside the handler for the SelectionChanged event "manually", depending on some checks. – Felipe Guajardo Dec 1 '10 at 13:30.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions